package com.orange.adminapi.controller.car;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.orange.adminapi.service.user.UserCarService;
import com.orange.core.pojo.PageReqDto;
import com.orange.core.pojo.R;
import com.orange.core.pojo.entity.user.UserCar;
import com.orange.core.pojo.req.car.UserCarPageReq;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 车辆管理
 */
@RequiredArgsConstructor
@RestController
@RequestMapping("/userCar")
public class UserCarController {

    private final UserCarService userCarService;

    /**
     * 分页
     */
    @PreAuthorize("hasAuthority(T(com.orange.core.pojo.enums.EPermission).CAR_LIST.permission.identifier)")
    @GetMapping("/page")
    public R<Page<UserCar>> page(@RequestBody PageReqDto<UserCarPageReq> req) {
        return R.ok(userCarService.page(req));
    }
}
